//
//  GameRecordCell.m
//  Mahjong
//
//  Created by 饶首建 on 17/6/21.
//  Copyright © 2017年 com.ikamobile.com. All rights reserved.
//

#import "GameRecordCell.h"

#import "RecordTableViewCell.h"
#import "ResultModel.h"
#import "ActionModel.h"

@interface GameRecordCell()<UITableViewDelegate,UITableViewDataSource>

@property (weak, nonatomic) IBOutlet UITableView *playerTableView;

@end

static NSString *kRecordTableViewCell = @"kRecordTableViewCell";

@implementation GameRecordCell

- (void)awakeFromNib {
    [super awakeFromNib];
    [_playerTableView registerNib:[UINib nibWithNibName:NSStringFromClass([RecordTableViewCell class]) bundle:nil] forCellReuseIdentifier:kRecordTableViewCell];
    _playerTableView.delegate = self;
    _playerTableView.dataSource = self;
    _playerTableView.tableFooterView = [UIView new];
}

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        self = [[NSBundle mainBundle]loadNibNamed:@"kGameRecordCell" owner:self options:nil].lastObject;
    }
    return self;
}

- (void)setGameModel:(GameModel *)gameModel{
    _gameModel = gameModel;
    [_playerTableView reloadData];
}

#pragma mark - UITableViewDataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return _gameModel.resultArr.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    RecordTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:kRecordTableViewCell forIndexPath:indexPath];
    cell.gameModel = _gameModel;
    cell.owner = _owner;
    cell.rm = _gameModel.resultArr[indexPath.row];
    cell.tagClickBlock = ^(id data){
        if (_getTagClickBlock) {
            _getTagClickBlock(data);
        }
    };
    return cell;
}

#pragma mark - UITableViewDelegate
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return _height/4;
}



@end
